package localdatetime;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : LocalDateTimeTest
 * @Author : 54061
 * @Date: 2022/2/12 14:04
 */
/*
    计算你活了多久
        long until(Temporal endExclusive, TemporalUnit unit)
            Temporal endExclusive: 传入的是截止时间的LocalDateTime对象
            TemporalUnit unit : 间隔时间的单位


        long getLong(TemporalField field)
            TemporalField是接口,实现类: ChronoField是枚举 (此类中枚举的是时间单位)


 */
public class LocalDateTimeTest {
    public static void main(String[] args) {
        //创建LocalDateTime对象
        LocalDateTime birthDate = LocalDateTime.of(1990, 1, 1, 8, 8, 8);

        //调用 直到  方法
        long days = birthDate.until(LocalDateTime.now(), ChronoUnit.DAYS);

        System.out.println("days = " + days);


    }
}
